package code.android.lovephone.receiver;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.telephony.SmsMessage;
import android.util.Log;

public class LPBroadcastReceiverSMS extends BroadcastReceiver 
{
	public static final String DEBUG_TAG = "LovePhoneBroadcastReceiverSMS";
	
	@Override
	public void onReceive(Context context, Intent intent) 
	{
		Bundle bundle = intent.getExtras();

		SmsMessage[] msgs = null;

		String call_number = "";

		if (bundle != null) 
		{
			Object[] pdus = (Object[]) bundle.get("pdus");

			msgs = new SmsMessage[pdus.length];
			
			for (int i = 0; i < msgs.length; i++) 
			{
				msgs[i] = SmsMessage.createFromPdu((byte[]) pdus[i]);
				
				call_number += msgs[i].getOriginatingAddress();
			}
			
			Log.e(DEBUG_TAG, call_number);
		}

	}

}
